﻿<!DOCTYPE html>
<html>
<head>
  <title>Parallel Route Links</title>
  <!-- Copyright 1998-2021 by Northwoods Software Corporation. -->
  <meta name="description" content="TypeScript: Custom non-Orthogonal non-Bezier Links that have parallel routings for multiple links connecting the same pair of ports." />
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <script src="../assets/js/goSamples.js"></script> <!-- this is only for the GoJS Samples framework -->
</head>
<body>
  <div id="sample">
    <div id="myDiagramDiv" style="border: solid 1px black; width:100%; height:600px"></div>
    <p>
      A <b>ParallelRouteLink</b> is a custom <a>Link</a> that overrides <a>Link.computePoints</a>
      in order to produce a middle segment that is parallel to the routes of other <b>ParallelRouteLink</b>s
      connecting the same two ports.
    </p>
  </div>

  <script type="module" id="code">
    import * as go from "../release/go-module.js";
    import { ParallelRouteLink } from './ParallelRouteLink.js';

    if (window.goSamples) goSamples(); // init for the samples -- you don't need to call this
    const $ = go.GraphObject.make;

    const myDiagram = $(go.Diagram, 'myDiagramDiv', {
        'undoManager.isEnabled': true
    });
    myDiagram.nodeTemplate =
        $(go.Node, 'Auto', new go.Binding('location', 'loc', go.Point.parse), $(go.Shape, {
            portId: '',
            fromLinkable: true, toLinkable: true,
            fromLinkableDuplicates: true, toLinkableDuplicates: true,
            cursor: 'pointer'
        }, new go.Binding('fill', 'color')), $(go.TextBlock, { margin: 8 }, new go.Binding('text')));
    myDiagram.linkTemplate =
        $(ParallelRouteLink, {
            relinkableFrom: true, relinkableTo: true,
            reshapable: true // , resegmentable: true
        }, $(go.Shape, { strokeWidth: 2 }, new go.Binding('stroke', 'fromNode', (node) => node.port.fill).ofObject()), $(go.Shape, { toArrow: 'OpenTriangle', strokeWidth: 1.5 }, new go.Binding('stroke', 'fromNode', (node) => node.port.fill).ofObject()));
    myDiagram.model = new go.GraphLinksModel([
        { key: 1, text: 'Alpha', color: 'lightblue', loc: '0 0' },
        { key: 2, text: 'Beta', color: 'orange', loc: '130 70' },
        { key: 3, text: 'Gamma', color: 'lightgreen', loc: '0 130' }
    ], [
        { from: 1, to: 2 },
        { from: 2, to: 1 },
        { from: 1, to: 3 },
        { from: 1, to: 3 },
        { from: 3, to: 1 },
        { from: 1, to: 3 },
        { from: 1, to: 3 }
    ]);

    window.myDiagram = myDiagram; // Attach to the window for console debugging
  </script>
</body>
</html>
